package drds.datasource.connection_pool;


import lombok.Getter;
import lombok.Setter;

import java.util.Date;


public class DataSourceState {

    @Setter
    @Getter
    protected String name;


    @Setter
    @Getter
    protected String url;
    @Setter
    @Getter
    protected String userName;

    @Setter
    @Getter
    protected boolean removeAbandoned;
    @Setter
    @Getter
    protected int initialSize;
    @Setter
    @Getter
    protected int minIdle;
    @Setter
    @Getter
    protected int maxActive;
    @Setter
    @Getter
    protected int queryTimeout;
    @Setter
    @Getter
    protected int transactionQueryTimeout;

    @Setter
    @Getter
    protected boolean testOnBorrow;
    @Setter
    @Getter
    protected boolean testOnReturn;
    @Setter
    @Getter
    protected boolean testWhileIdle;
    @Setter
    @Getter
    protected boolean defaultAutoCommit;


    @Setter
    @Getter
    protected int activeCount;

    @Setter
    @Getter
    protected int activePeak;

    @Setter
    @Getter
    protected long activePeakTime;

    @Setter
    @Getter
    protected int poolingCount;

    @Setter
    @Getter
    protected int poolingPeak;

    @Setter
    @Getter
    protected long poolingPeakTime;

    @Setter
    @Getter
    protected long connectCount;

    @Setter
    @Getter
    protected long closeCount;

    @Setter
    @Getter
    protected long waitThreadCount;

    @Setter
    @Getter
    protected long notEmptyWaitCount;

    @Setter
    @Getter
    protected long notEmptyWaitNanos;

    @Setter
    @Getter
    protected long logicConnectErrorCount;

    @Setter
    @Getter
    protected long physicalConnectCount;

    @Setter
    @Getter
    protected long physicalCloseCount;

    @Setter
    @Getter
    protected long physicalConnectErrorCount;

    @Setter
    @Getter
    protected long executeCount;

    @Setter
    @Getter
    protected long errorCount;

    @Setter
    @Getter
    protected long commitCount;

    @Setter
    @Getter
    protected long rollbackCount;
    @Setter
    @Getter
    protected long pstmtCacheHitCount;
    @Setter
    @Getter
    protected long pstmtCacheMissCount;
    @Setter
    @Getter
    protected long startTransactionCount;

    @Setter
    @Getter
    protected long keepAliveCheckCount;


    public Date getPoolingPeakTime() {
        if (poolingPeakTime <= 0) {
            return null;
        }

        return new Date(poolingPeakTime);
    }


    public Date getActivePeakTime() {
        if (activePeakTime <= 0) {
            return null;
        }

        return new Date(activePeakTime);
    }

}
